package org.etlt.gui.panel;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class ProjectCreatePanel extends JPanel{

    public ProjectCreatePanel() {
        init();
    }

    public void init() {
        setLayout(new BorderLayout());

        JPanel displayPanel = new JPanel();
        displayPanel.setLayout(new GridLayout(4, 3, 5, 5));
        JLabel nameLabel = new JLabel("名称：");
//        totalLabel.setBounds(new Rectangle());
        final JTextField nameField = new JTextField();

//        totalField.setDocument(new DoubleDocument());

        displayPanel.add(nameLabel);
        displayPanel.add(nameField);


        JLabel parallelLabel = new JLabel("并行执行：");
        final JTextField parallelField = new JTextField();

        displayPanel.add(parallelLabel);
        displayPanel.add(parallelField);
        // resources
        JLabel resourcesLabel = new JLabel("资源：");
        JLabel resourceNameLable = new JLabel("资源名称");
        JTextField resourceNameField = new JTextField();
        final String dbType = "DATA_BASE";
        JComboBox typeField = new JComboBox();
        typeField.setModel(new DefaultComboBoxModel(new Object[]{dbType}));
        typeField.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                if(typeField.getSelectedItem().equals(dbType)){

                }
            }
        });
        displayPanel.add(resourcesLabel);
        displayPanel.add(resourceNameLable);
        displayPanel.add(resourceNameField);
        displayPanel.add(typeField);

        add(displayPanel, BorderLayout.CENTER);

        JPanel operationPanel = new JPanel();
        JButton generateButton = new JButton("Generate");
        generateButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
            }
        });
        operationPanel.add(generateButton);

        add(operationPanel, BorderLayout.SOUTH);
    }


}
